/* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable import/first */
/*
 * @Author: your name
 * @Date: 2021-10-05 11:05:48
 * @LastEditTime: 2021-11-06 01:10:08
 * @LastEditors: Shentong
 * @Description: 我的优惠券
 * @FilePath: /distribution/src/pages/coupon/index.tsx
 */
import React, { useEffect, useState  } from 'react';
import Taro, { useRouter } from '@tarojs/taro';
import { View, Image } from "@tarojs/components";

import { getCouponList } from '@/api/coupon'

import styles from './index.module.scss'

import priceIcon from '@/src/assets/icon/price.png'


import { getCashList } from '@/api/pay'


const account = () => {
    const [cashList, setCashList] = useState<Array<any>>([])

    // 提现记录
    
    const dataList = () => {
        const params = {
            pageNum:1,
            pageSize: 20
        }
        getCashList(params).then(res => {
            const {data} = res
            setCashList(data)
        })
    }

    useEffect(() => {
        dataList()
    }, [])



    const Price = 100.89

    const array = [
        {
            id: 1,
            name: '提现',
            time: '2019-08-09  22:22:11',
            price: '90'
        },
        {
            id: 2,
            name: '提现',
            time: '2019-08-09  22:22:11',
            price: '90'
        },
        {
            id: 3,
            name: '提现',
            time: '2019-08-09  22:22:11',
            price: '90'
        },
    ]

    const subChange = () => {
        Taro.navigateTo({
            url: '/pages/record/index'
        })
    }
    return (
        <View className={styles.account}>
            <View className={styles.imgIcon}>
                <Image src={priceIcon} className={styles.img}></Image>
            </View>
            <View className={styles.text}>账户余额</View>
            <View className={styles.price}> 
                {Price}
                元
            </View>
            <View className={styles.btn} onClick={subChange}>
                提现
            </View>

            <View className={styles.notes}>提现记录</View>


            {
                array.map((item, index) => {
                    return (
                        <View className={styles.list} key={index}>
                            <View className={styles.name}>{item.name}</View>
                            <View className={styles.time}>{item.time}</View>
                            <View className={styles.oprice}>¥{item.price}</View>
                        </View>
                    )
                })
            }

        </View>
    )
}

export default account;
